class Person: def __init__(self,nm,ct): self.name = nm self.city = ct def showdata(self): print("Name is ", self.name) print("City is ", self.city) class Employee(Person): def __init__(self,nm,ct,jb,sl): super().__init__(nm,ct) self.job = jb self.salary = sl def showdata(self): super().showdata() print("Job is ",self.job) print("Salary is ", self.salary) class Manager(Employee): def __init__(self,nm,ct,jb,sl,br): super().__init__(nm,ct,jb,sl) self.branch = br def showdata(self): super().showdata() print("Branch is ",self.branch) a=Person("Amit jain","Amrvati") a.showdata() b=Employee("Raj Rathi","Raipur","Clerk",15600) b.showdata() c=Manager("M.Rao","Mumbai","Sr.Mgr",45600,"SBI-Amt") c.showdata()
Name is Amit Jain City is Amravati Name is Raj Rathi City is Raipur Job is Clerk Salary is 15600 Name is M.Rao City is Mumbai Job is Sr.Mgr Salary is 45600 Branch is SBI-Amt
class Person: def __init__(self,nm,ct): self.name = nm self.city = ct def showdata(self): print("Name is ", self.name) print("City is ", self.city) class Employee(Person): def __init__(self,nm,ct,jb,sl): super().__init__(nm,ct) self.job = jb self.salary = sl def showdata(self): super().showdata() print("Job is ",self.job) print("Salary is ", self.salary) class Manager(Employee): def __init__(self,nm,ct,jb,sl,br): super().__init__(nm,ct,jb,sl) self.branch = br def showdata(self): super().showdata() print("Branch is ",self.branch) a=Person("Amit jain","Amrvati") a.showdata() b=Employee("Raj Rathi","Raipur","Clerk",15600) b.showdata() c=Manager("M.Rao","Mumbai","Sr.Mgr",45600,"SBI-Amt") c.showdata()
Name is Amit Jain City is Amravati Name is Raj Rathi City is Raipur Job is Clerk Salary is 15600 Name is M.Rao City is Mumbai Job is Sr.Mgr Salary is 45600 Branch is SBI-Amt
class Student: def __init__(self,rn,nm,br): self.rollno=rn self.name = nm self.branch = br def showdata(self): print("RollNo is",self.rollno) print("Name is" ,self.name) print("Branch is" ,self.branch) class Exam(Student): def __init__(self,r,n,b,*mks): super().__init__(r,n,b) self.marks = mks class Marksheet(Exam): def total(self): t=sum(self.marks) return t def percentage(self): c=len(self.marks) p=sum(self.marks)/c return p def result(self): for mk in self.marks: if mk < 40 : return "Fail" else: return "Pass" a=Marksheet(4117,"Amit Jain","CSE-3",57,68,34,56,62) a.showdata() print("Total is",a.total()) print("Prcentage is",a.percentage()) print("Result is",a.result())
RollNo is 4117 Name is Amit Jain Branch is CSE-3 Total is 277 Prcentage is 55.4 Result is Fail
class Person: def __init__(self,nm,ct): self.name=nm self.city=ct def showdata(self): print("Name is ",self.name) print("City is ",self.city) class Student(Person): def __init__(self,rn,nm,ct,br): self.rollno=rn super().__init__(nm,ct) self.branch=br def showdata(self): print("Rollno is",self.rollno) super().showdata() print("Branch is",self.branch) class Teacher(Person): def __init__(self,nm,ct,*subs): super().__init__(nm,ct) self.subjects=subs def showdata(self): super().showdata() print("Subjects are") for sub in self.subjects: print(sub) a=Person("Amit jain","Amrvati") a.showdata() b=Student(4117,"Raj Joshi","Nagpur","CSE-3") b.showdata() c=Teacher("Raja Kumar","Raipur","Hin","His","Geo") c.showdata()
Name is Amit Jain City is Amravati Rollno is 4117 Name is Raj Rathi City is Nagpur Branch is CSE-3 Name is Raja Kumar City is Raipur Subjects are Hin His Geo
class Person: def __init__(self,nm,ct): self.name=nm self.city=ct def showdata(self): print("Name is ",self.name) print("City is ",self.city) class Employee(Person): def __init__(self,nm,ct,jb,sl,ad): super().__init__(nm,ct) self.job=jb self.salary=sl self.advance=ad def showdata(self): super().showdata() print("Job is ",self.job) print("Salary is ",self.salary) print("Advance is ",self.advance) def payment(self): p=self.salary-self.advance print("payment is ",p) class Worker(Person): def __init__(self,nm,ct,wg,wd): super().__init__(nm,ct) self.wages=wg self.wdays=wd def showdata(self): super().showdata() print("Wages is ",self.wages) print("Wdays is ",self.wdays) def payment(self): p=self.wages*self.wdays print("payment is ",p) a=Person("Amit jain","Amrvati") a.showdata() b=Employee("Raj Rathi","Nagpur","Clerk",25000,5000) b.showdata() b.payment() c=Worker("Raja Kumar","Raipur",500,25) c.showdata() c.payment()
Name is Amit Jain City is Amravati Name is Raja Kumar City is Raipur Wages is 500 Wdays is 25 Payment is 12500 Name is Raj Rathi City is Nagpur Job is Clerk Salary is 25000 Advance is 5000 Payment is 20000
class Person: def __init__(self,name,city): self.name=name self.city=city def showdata(self): print("Name is ",self.name) print("City is ",self.city) class Test: def __init__(self,subject,marks): self.subject=subject self.marks=marks def showdata(self): print("Subject is ",self.subject) print("Marks are ",self.marks) class Student(Person,Test): def __init__(self,rollno,name,city,subject,marks): self.rollno=rollno Person.__init__(self,name,city) Test.__init__(self,subject,marks) def showdata(self): print("RollNo is",self.rollno) Person.showdata(self) Test.showdata(self) a=Student(4117,"Raj Rathi","Amravati","CET",55) a.showdata()
RollNo is 4117 Name is Raj Rathi City is Amravati Subject is CET Marks are 55